<template>
  <div class="busi-form-container">
    <el-dialog
      v-if="dialogFormVisible"
      v-el-drag-dialog
      class="busi-form-container__dialog"
      :visible.sync="dialogFormVisible"
      :close-on-click-modal="false"
      :top="'10vh'"
      :width="winWidth+'px'"
      :append-to-body="appendToBody"
      :title="title"
      @opened="dialogOpend"
      @close="closeDialog"
      @open="dialogOpen"
    >
      <div v-if="loading" v-loading="loading" element-loading-text="正在加载..." class="el-dialog__body" />
      <div v-focus="autoFocus" class="basicform-panel">

        <el-scrollbar v-if="formType==='form'" class="basicform-panel-scrollbar" :native="false" tag="div">
          <!-- 业务模块自定义表单插槽 -->
          <slot v-if="!loading" :vo="vo" :can-edit="canEdit" />
          <!-- 多附件上传，兼容BasicForm标签wfAttach=true旧版功能 -->
          <el-form v-if="wfAttach&&!loading" class="attachments-container">
            <div class="el-table el-table--fit el-table--border" style="z-index:2">
              <div class="el-table__body-wrapper">
                <table class="el-table__body" cellspacing="0" cellpadding="0" border="0">
                  <tbody>
                    <tr>
                      <td class="tdlbl tdw17">附件</td>
                      <td colspan="3" class="tdcont tdw83" style="text-align: left;">
                        <Attachment v-if="wfAttach&&!loading" ref="attachments" :vo="vo" :can-edit="canEdit" :online-file="onlineFile" :viewer="onlineViewer" :attach-edit="attachEdit" :attachments="vo.passenger.attachments" :attachs-type="wfAttachsType" :batch-save-namefield="batchSaveNamefield" />
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </el-form>
        </el-scrollbar>
        <template v-if="formType==='tabs'">
          <!-- 业务模块自定义表单插槽 -->
          <slot v-if="!loading" :vo="vo" :can-edit="canEdit" />
          <!-- 多附件上传，兼容BasicForm标签wfAttach=true旧版功能 -->
          <el-form v-if="wfAttach&&activeTabIndex==wfAttachTabIndex&&!loading" class="attachments-container">
            <div class="el-table el-table--fit el-table--border" style="z-index:2">
              <div class="el-table__body-wrapper">
                <table class="el-table__body" cellspacing="0" cellpadding="0" border="0">
                  <tbody>
                    <tr>
                      <td class="tdlbl tdw17">附件</td>
                      <td colspan="3" class="tdcont tdw83" style="text-align: left;">
                        <Attachment v-if="wfAttach&&activeTabIndex==wfAttachTabIndex&&!loading" ref="attachments" :online-file="onlineFile" :viewer="onlineViewer" :attach-edit="attachEdit" :vo="vo" :can-edit="canEdit" :attachments="vo.passenger.attachments" :attachs-type="wfAttachsType" :batch-save-namefield="batchSaveNamefield" />
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </el-form>
        </template>
      </div>

      <div v-if="!loading" slot="footer" class="dialog-footer">
        <el-button
          v-for="(btn,key) in footerBtns"
          :key="key"
          :disabled="doing"
          :class="{'custom_plain_default_btn':btn.btnType===null || btn.btnType==='' || btn.btnType===undefined}"
          :plain="btn.btnType===null || btn.btnType==='' || btn.btnType===undefined"
          :icon="'el-icon-'+btn.btnIcon"
          :type="btn.btnType?btn.btnType:''"
          @click="btn.btnClick"
        >{{ btn.btnName }}</el-button>
      </div>
    </el-dialog>

    <el-dialog v-if="uploading" v-el-drag-dialog :visible.sync="uploading" :append-to-body="true" :close-on-click-modal="false" width="600px" title="上传文件">
      {{ uploadingFile.name }}
      <el-progress :text-inside="true" :stroke-width="20" :percentage="uploadingFile.progress" status="success" />
    </el-dialog>

    <el-dialog v-if="iconDialogFormVisible" v-el-drag-dialog :visible.sync="iconDialogFormVisible" :append-to-body="true" :close-on-click-modal="true" width="1250px" :title="iconDialogTitle">
      <Icons />
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import Icons from '@/wapp/support/icons/index'
import { generateTitle } from '@/global/utils/i18n'

export default {
    name: 'Basicform',
    components: {
        Icons
    },
    props: {
        title: { type: String, default: '' },
        moduleCode: { type: String, default: null },
        toolbarBtns: { type: Array, default: function() { return [] } },
        onBasicFormBeforeOpen: { type: Function, default: function($scope, vo, defer) { defer.resolve(true) } },
        onBasicFormOpened: { type: Function, default: function($scope, vo) { } },
        onBasicFormEditObject: { type: Function, default: function($scope, vo) { } },
        onBasicFormBeforeSubmit: { type: Function, default: function($scope, vo, defer) { defer.resolve(true) } },
        onBasicFormSubmitConfirm: { type: Function, default: null },
        onBasicFormSubmited: { type: Function, default: function($scope, vo) { } },
        winWidth: { type: Number, default: 800 },
        winHeight: { type: Number, default: 600 },
        appendToBody: { type: Boolean, default: false },
        autoFocus: { type: Boolean, default: true },
        wfAttach: { type: Boolean, default: false },
        wfAttachsType: { type: String, default: 'ATTACH' },
        wfAttachTabIndex: { type: Number, default: function() { return 0 } },
        attachEdit: { type: Object, default: null },
        batchSaveNamefield: { type: String, default: '' },
        fixedHeight: { type: Boolean, default: false },
        onlineFile: { type: String, default: '.doc,.docx,.xls,.xlsx,.ppt,.pptx' }, // doc转pdf在线预览文件格式
        onlineViewer: { type: String, default: 'pdfjs' } // 在线预览文件方式
    },
    data() {
        return {
            dialogFormVisible: false,
            moduleInfo: {},
            vo: { },
            callback: null,
            isnew: false,
            canEdit: 1,
            activeTabIndex: 0,
            loading: false,
            doing: false,
            uploadFiles: [],
            uploadingFile: null,
            uploading: false,
            footerBtns: [],
            submitInnerForm: false,
            formType: 'form',
            refsAttachments: [],
            iconDialogFormVisible: false,
            iconDialogTitle: '选择图标'
        }
    },
    computed: {
        ...mapGetters([
            'loginUser'
        ])
    },
    watch: {
        wfAttach(val) {
            if (val && this.vo.passenger && this.vo.passenger.attachments === undefined) {
                this.vo.passenger.attachments = []
            }
        }
    },
    created() {
        this.$bus.on('openBusiform', this.openBusiform)
        this.$bus.on('addUploadFiles', this.addUploadFiles)
        this.$bus.on('submitBusiform', this.submitBusiform)
    },
    beforeDestroy() {
        this.$bus.off('openBusiform', this.openBusiform)
        this.$bus.off('addUploadFiles', this.addUploadFiles)
        this.$bus.off('submitBusiform', this.submitBusiform)
    },
    mounted() {

    },
    methods: {
        async openBusiform(moduleInfo, row, canEdit, callback) {
            if (this.moduleCode != null && this.moduleCode !== moduleInfo.moduleCode) {
                return
            }
            const _this = this
            if (_this.loading) {
                return
            }

            _this.loading = true

            _this.moduleInfo = moduleInfo
            _this.canEdit = canEdit
            _this.callback = callback || null
            _this.refsAttachments = []

            let moduleCode = this.moduleCode || moduleInfo.moduleCode
            if (!moduleCode && this.moduleInfo.insertUrl) {
                moduleCode = this.moduleInfo.insertUrl.split('/')[2]
                this.title = generateTitle({ formTitle: this.title, code: moduleCode }, this)
            }

            let res = null
            if (row === null) {
                res = await this.$app.addNew(moduleInfo.addNewUrl)
                _this.isnew = true
            } else {
                res = await this.$app.getById(moduleInfo.getByIdUrl, row.id)
                _this.canEdit = canEdit
                _this.isnew = false
            }

            if (res !== null && res.code === 'success') {
                _this.vo = res.body.vo
                _this.vo.isnew = _this.isnew

                new Promise((resolve, reject) => {
                    _this.onBasicFormBeforeOpen(_this, _this.vo, { resolve, reject })
                }).then(result => {
                    if (result) {
                        _this.dialogFormVisible = true
                        _this.loading = false

                        _this.$nextTick(function() {
                            _this.onBasicFormOpened(_this, _this.vo)
                            _this.setFooterBtns()
                            this.setFormStyle()
                        })

                        if (_this.wfAttach) {
                            if (_this.vo.passenger.attachments === undefined) {
                                _this.vo.passenger.attachments = []
                            }
                        }
                    } else {
                        _this.dialogFormVisible = false
                        _this.loading = false
                    }
                }).catch(e => {
                    _this.dialogFormVisible = false
                    _this.loading = false
                })
            } else {
                _this.loading = false
                _this.$alert(res.message, { type: 'error' })
            }
        },
        // 表单固定高度时修改表单样式
        setFormStyle() {
            var _this = this
            // 获取表单
            const dialogBody = document.querySelector('.busi-form-container__dialog .el-dialog__body .basicform-panel')
            // 获取附件组件的高度
            let attachHeight = 0
            if (this.wfAttach) {
                const attach = dialogBody.querySelector('.attachments-container')
                if (attach) attachHeight = attach.offsetHeight
            }
            function setFormStyle() {
                if (_this.fixedHeight) {
                    // 表单是否是标签页
                    if (_this.formType === 'form') {
                        dialogBody.style.height = (_this.winHeight - 161 + attachHeight) + 'px'
                        dialogBody.style.overflowY = 'auto'
                        if (dialogBody.querySelector('.basicform-panel-scrollbar .el-scrollbar__wrap') !== null) {
                            dialogBody.querySelector('.basicform-panel-scrollbar .el-scrollbar__wrap').style.height = (_this.winHeight - 161 + attachHeight) + 'px'
                            dialogBody.querySelector('.basicform-panel-scrollbar .el-scrollbar__wrap').style.display = 'none'

                            _this.$nextTick(() => {
                                dialogBody.querySelector('.basicform-panel-scrollbar .el-scrollbar__wrap').style.display = ''
                            })
                        }
                    }
                    // 固定表单高度
                    setTimeout(() => {
                        // 获取滚动条区域固定高度
                        const dialogBodyForm = dialogBody.querySelector('.basicform-panel-scrollbar .el-scrollbar__wrap')
                        if (dialogBodyForm !== null) {
                            const dialogBodyForm2 = dialogBodyForm.querySelector('.el-form')
                            if (dialogBodyForm2 !== null && dialogBodyForm2.offsetHeight > (_this.winHeight - 161)) {
                                // 添加类设置边框
                                dialogBody.classList.add('busi-form-container-border')
                            }
                        }
                        // 获取标签页
                        const dialogBodyTabs = document.querySelector('.busi-form-container__dialog .el-dialog__body .el-tabs__content')
                        if (dialogBodyTabs !== null) {
                            dialogBody.classList.remove('busi-form-container-border')
                            // 获取标签页中的标签
                            const tabPane = dialogBodyTabs.querySelectorAll('.el-tab-pane')
                            // 遍历设置高度
                            tabPane.forEach(tab => {
                                tab.style.height = _this.winHeight - 215 + 'px'
                                tab.style.overflowY = 'auto'
                                tab.style.overflowX = 'hidden'
                                tab.querySelector('.el-scrollbar .el-scrollbar__wrap').style.height = _this.winHeight - 215 + 'px'
                                const tabForm = tab.querySelector('.el-scrollbar .el-scrollbar__wrap').querySelector('.el-form')
                                if (tabForm !== null) {
                                    if (tabForm.offsetHeight > (_this.winHeight - 215)) {
                                        tab.classList.add('busi-form-container-border')
                                    }
                                }
                                if (tab.style.display !== 'none') {
                                    tab.style.display = 'none'
                                    // _this.$nextTick(() => {
                                    //     tab.style.display = ''
                                    // })
                                    setTimeout(() => { tab.style.display = '' }, 0)
                                }
                            })
                        }
                    }, 90)
                }
            }
            setFormStyle()
            _this.$nextTick(() => {
                setTimeout(() => {
                    // 获取页面内容判断是否含有便签
                    const dialogBodyTabs = document.querySelector('.busi-form-container__dialog .el-dialog__body .el-tabs__content')
                    if (dialogBodyTabs !== null && _this.formType !== 'tabs') {
                        _this.formType = 'tabs'
                    } else if (dialogBodyTabs === null && _this.formType !== 'form') {
                        _this.formType = 'form'
                    }
                    setFormStyle()
                    _this.$nextTick(() => {
                        setTimeout(() => {
                            // 获取外层元素
                            const dialogScrollbar = dialogBody.querySelector('.basicform-panel-scrollbar')
                            // 获取标签外层元素
                            const dialogTabsScrollbar = dialogBody.querySelector('.el-tabs__content')
                            if (dialogTabsScrollbar !== null) {
                                // 有标签页循环判断高度添加类设置边框线
                                const tabPaneScrollbar = dialogTabsScrollbar.querySelectorAll('.el-tab-pane')
                                tabPaneScrollbar.forEach(item => {
                                    if (item.querySelector('.tab-pane-wrapper') !== null) {
                                        const scrollbarWrap = item.querySelector('.tab-pane-wrapper')
                                        const scrollbarView = scrollbarWrap.querySelector('.el-scrollbar__view')
                                        if (scrollbarView.offsetHeight > scrollbarWrap.offsetHeight) {
                                            item.querySelector('.tab-pane-wrapper').classList.add('el-scrollbar__border')
                                        }
                                    }
                                })
                            } else {
                                const scrollbarView = dialogScrollbar.querySelector('.el-scrollbar__view')
                                if (scrollbarView.offsetHeight > dialogScrollbar.offsetHeight) {
                                    dialogScrollbar.classList.add('el-scrollbar__border')
                                }
                            }
                        }, 50)
                    })
                }, 50)
                // dialogBody.style.display = 'none'
                // setTimeout(() => {
                //     dialogBody.style.display = ''
                // }, 0)
            })
        },
        async submitBusiform(moduleInfo, saveCallBack, actionType) {
            if (this.moduleCode != null && moduleInfo.moduleCode !== undefined && this.moduleCode !== moduleInfo.moduleCode) {
                return
            }

            const _this = this
            if (_this.doing) {
                return
            }

            this.formValidate(() => {
                // saveCallBack：主表单新增内嵌子表对象时，先执行主表单提交，主表单提交保存成功后触发saveCallBack
                if (saveCallBack === undefined) {
                    _this.doing = true
                }
                // actionType：内嵌子表调用主表保存时，actionType=InnerTableSave，暂无其它场景使用actionType参数
                _this.actionType = actionType

                new Promise((resolve, reject) => {
                    _this.onBasicFormBeforeSubmit(_this, _this.vo, { resolve, reject })
                }).then(async result => {
                    if (result) {
                        let res = null
                        const vobak = JSON.parse(JSON.stringify(_this.vo))
                        delete vobak.isnew
                        if (_this.isnew) {
                            res = await this.$app.insert(_this.moduleInfo.insertUrl, vobak)
                        } else {
                            res = await this.$app.update(_this.moduleInfo.updateUrl, vobak)
                        }
                        if (res.code === 'success') {
                            _this.isnew = false
                            if (res.body.vo && (_this.vo.id === null || _this.vo.id === '' || _this.vo.id !== res.body.vo.id)) {
                                _this.vo.id = res.body.vo.id
                            }

                            new Promise(async(resolve, reject) => {
                                let attachments = _this.$attachments
                                if (attachments === undefined && _this.$vnode.context.$refs['busiform']) {
                                    attachments = _this.$vnode.context.$refs['busiform'].$attachments
                                }

                                // 表单中有文件时先上传表单文件
                                if (_this.uploadFiles.length > 0) {
                                    _this.startUploadFile(async(callBack) => {
                                        // 上传附件
                                        _this.wfInstance = { moduleCode: _this.moduleCode, bodyDocId: '' }
                                        if (this.refsAttachments.length > 0) {
                                            // 一个表单中有多个附件组件
                                            for (let i = 0; i < _this.refsAttachments.length; i++) {
                                                const res = await _this.refsAttachments[i].uploadWflowAttach(_this)
                                                if (res.code === 'success') {
                                                    if (_this.refsAttachments.length === (i + 1)) {
                                                        resolve(true)
                                                    }
                                                }
                                            }
                                        } else if (attachments !== undefined) {
                                            // 一个表单中有一个附件组件
                                            attachments.uploadWflowAttach(_this).then(res => {
                                                if (res.code === 'success' && callBack) {
                                                    resolve(true)
                                                }
                                            })
                                        } else if (callBack) {
                                            resolve(true)
                                        }
                                    })
                                } else if (this.refsAttachments.length > 0) {
                                    // 一个表单中有多个附件组件
                                    _this.wfInstance = { moduleCode: _this.moduleCode, bodyDocId: '' }

                                    for (let i = 0; i < _this.refsAttachments.length; i++) {
                                        const res = await _this.refsAttachments[i].uploadWflowAttach(_this)
                                        if (res.code === 'success') {
                                            if (_this.refsAttachments.length === (i + 1)) {
                                                resolve(true)
                                            }
                                        }
                                    }
                                } else if (attachments !== undefined) {
                                    // 一个表单中有一个附件组件
                                    _this.wfInstance = { moduleCode: _this.moduleCode, bodyDocId: '' }
                                    attachments.uploadWflowAttach(_this).then(res => {
                                        if (res.code === 'success') {
                                            resolve(true)
                                        }
                                    })
                                } else {
                                    resolve(true)
                                }
                            }).then(result => {
                                _this.onBasicFormSubmited(_this, _this.vo, res)

                                if (saveCallBack === undefined) {
                                    if (this.callback !== null) {
                                        this.callback(res, _this.vo)
                                    } else {
                                        _this.$message({ type: res.code, message: res.message, showClose: true })
                                    }
                                    _this.dialogFormVisible = false
                                } else {
                                    _this.isnew = false
                                    _this.vo.isnew = false
                                    saveCallBack(true)
                                }

                                _this.$bus.emit('refreshListData', null, null, null, this.moduleCode)
                            })
                        } else if (res.code === 'confirm') {
                            new Promise((resolve, reject) => {
                                if (_this.onBasicFormSubmitConfirm !== null) {
                                    _this.onBasicFormSubmitConfirm(_this, _this.vo, { resolve, reject })
                                } else {
                                    this.$confirm(res.message, '确认操作', { type: 'warning' })
                                        .then(async() => {
                                            resolve(true)
                                        })
                                        .catch(err => {
                                            reject(err)
                                        })
                                }
                            }).then(result => {
                                if (result) {
                                    _this.vo.passenger.confirmContinue = true
                                    _this.submitBusiform(moduleInfo, saveCallBack)
                                }
                            })
                        } else {
                            _this.$alert(res.message, '操作提示', { type: 'error' })
                        }
                    }
                    _this.doing = false
                }).catch(e => {
                    _this.doing = false
                })
            }, () => {
                if (saveCallBack !== undefined) {
                    saveCallBack(false)
                }
            }, this.canEdit, this.$el)
        },
        onTabClick(tab) {
            this.activeTabIndex = tab.index

            const dialogBodyTabs = document.querySelector('.busi-form-container__dialog .el-dialog__body .el-tabs__content')
            const tabPane = dialogBodyTabs.querySelectorAll('.el-tab-pane')
            const tabForm = tabPane[tab.index].querySelector('.el-scrollbar .el-scrollbar__wrap').querySelector('.el-form')
            if (tabForm !== null) {
                this.$nextTick(() => {
                    if (tabForm.offsetHeight > (this.winHeight - 215)) {
                        tabPane[tab.index].classList.add('busi-form-container-border')
                    }
                })
            }
        },
        editObject() {
            const activeName = this.activeName
            this.loading = true

            this.$nextTick(() => {
                this.canEdit = 1
                this.refsAttachments = []

                this.onBasicFormEditObject(this, this.vo)

                this.loading = false
                this.activeName = activeName
                this.$nextTick(() => {
                    this.setFormStyle()
                    this.setFooterBtns()
                })
            })
        },
        closeDialog() {
            if (this.callback !== null) {
                this.callback({ code: 'cancel', message: '取消保存' })
            }
            this.dialogFormVisible = false
            this.moduleInfo = {}
            this.vo = {}
        },
        async setFooterBtns() {
            const formBtns = JSON.parse(JSON.stringify(this.toolbarBtns))

            if (this.toolbarBtns.length === 0) {
                formBtns.push({
                    id: 'btn_close',
                    btnName: '关 闭',
                    btnIcon: 'close',
                    btnClick: this.closeDialog,
                    btnPermission: '',
                    btnType: ''
                })

                if (this.canEdit === 1) {
                    formBtns.push({
                        id: 'btn_save',
                        btnName: '保 存',
                        btnIcon: 'check',
                        btnClick: this.submitBusiform,
                        btnPermission: 'saveObject',
                        btnType: 'primary'
                    })
                } else {
                    formBtns.push({
                        id: 'btn_edit',
                        btnName: '修 改',
                        btnIcon: 'edit',
                        btnClick: this.editObject,
                        btnPermission: 'editObject',
                        btnType: 'primary'
                    })
                }
            } else {
                formBtns.forEach((btn, i) => {
                    if (typeof this.toolbarBtns[i].btnClick === 'string') {
                        const btnClick = btn.btnClick.split('(')[0]
                        btn.btnClick = this[btnClick]
                        btn.btnClickFunc = btnClick
                    } else {
                        btn.btnClick = this.toolbarBtns[i].btnClick
                    }
                })
            }
            for (let i = 0; i < formBtns.length; i++) {
                const pcode = 'FOOTER_BTN$' + formBtns[i].btnPermission
                const hasPermission = await this.$store.dispatch('user/hasPermission', { 'href': this.$route.meta.href, 'pcode': pcode })
                if (!hasPermission) {
                    formBtns.splice(i--, 1)
                } else {
                    const item = formBtns[i]
                    item.btnI18nCode = item.btnI18nCode || (item.btnPermission || item.btnIcon).replace('Ids', '').replace('Object', '')
                    item.btnName = generateTitle(item, this)
                }
            }

            this.footerBtns = formBtns
        },
        selectIcon(iconDialogTitle) {
            if (iconDialogTitle) this.iconDialogTitle = iconDialogTitle
            this.$set(this, 'iconDialogFormVisible', true)
        },
        addUploadFiles(formItem, fileList, uploadFileModuleCode) {
            if (this.moduleCode != null && uploadFileModuleCode !== undefined && this.moduleCode !== uploadFileModuleCode) {
                return
            }

            for (let i = 0; i < this.uploadFiles.length; i++) {
                if (formItem.propName === this.uploadFiles[i].propName) {
                    if (formItem.propName === this.uploadFiles[i].propName && formItem.pid === this.uploadFiles[i].pid) {
                        this.uploadFiles.splice(i--, 1)
                    }
                }
            }
            formItem.fileList = fileList
            this.uploadFiles.push(formItem)
        },
        async startUploadFile(resolve) {
            const _this = this

            _this.uploading = true

            let uploadUrl = _this.moduleInfo.updateUrl.substring(0, _this.moduleInfo.updateUrl.lastIndexOf('/')) + '/upload'
            if (_this.moduleInfo.updateUrl.indexOf('?') !== -1) {
                uploadUrl += '?' + _this.moduleInfo.updateUrl.split('?')[1]
            }
            for (let i = 0; i < _this.uploadFiles.length; i++) {
                const formItem = _this.uploadFiles[i]

                let j = 0
                for (j = 0; j < formItem.fileList.length; j++) {
                    const file = formItem.fileList[j]
                    _this.uploadingFile = file
                    let nameField = formItem.nameField
                    let dataField = formItem.propName
                    if (j > 0) {
                        nameField = formItem.nameField + (j + 1)
                        dataField = formItem.propName + (j + 1)
                    }
                    const config = {
                        onUploadProgress: progressEvent => {
                            const complete = (progressEvent.loaded / progressEvent.total * 100 | 0)
                            _this.uploadingFile.progress = complete
                            _this.$forceUpdate()
                        }
                    }
                    let fieldUploadUrl = uploadUrl
                    if (formItem.downloadUrl !== undefined && formItem.downloadUrl !== null && formItem.downloadUrl !== '') {
                        fieldUploadUrl = formItem.downloadUrl.replace('/downloadById', '/upload').replace('/download', '/upload')
                    }
                    const uploadRst = await this.$app.upload(fieldUploadUrl, file.raw, { 'id': formItem.pid || this.vo.id, 'nameField': nameField, 'dataField': dataField }, config)

                    if (uploadRst.code !== 'success') {
                        _this.$message.error('“' + file.name + '”' + uploadRst.message)
                    }
                }

                if (j < formItem.fileList.length) {
                    return
                } else {
                    _this.uploadFiles.splice(i--, 1)
                }
            }
            if (_this.uploadFiles.length === 0) {
                setTimeout(() => {
                    _this.uploading = false
                    resolve(true)
                }, 100)
            }
        }
    }
}
</script>
<style lang="scss" scoped>
/deep/ .el-progress{
    margin: 20px auto
}
/deep/ .el-dialog__body{
    min-height:180px;
    overflow-y: auto;
    .basicform-panel{
        position: relative;
        overflow-x: hidden;
        .el-scrollbar{
            height: 100%;
            width: 100%;
            .el-scrollbar__wrap{
                overflow-x:hidden;
                margin-bottom: 0!important;
            }
        }
        .el-scrollbar__border{
            position:relative;
            &::before{
                content: '';
                position: absolute;
                border-right:1px solid #EBEEF5;
                top: 0;
                right: 0;
                height: 100%;
                z-index: 2;
            }
            &::after{
                content: '';
                position: absolute;
                border-bottom:1px solid #EBEEF5;
                bottom: 0;
                left: 0;
                width: 100%;
                z-index: 2;
            }
        }
    }
    .el-tabs{
        margin-top:-10px;
    }
    .busi-form-container-border{
        position:relative;
        &::before{
            content: '';
            position: absolute;
            border-top:1px solid #EBEEF5;
            top: 0;
            left: 0;
            width: 100%;
            z-index: 5;
        }
        &::after{
            content: '';
            position: absolute;
            border-top:1px solid #EBEEF5;
            bottom: 0;
            left: 0;
            width: 100%;
            z-index: 5;
        }
    }

    .inner-table-margin-top{
        margin-top: 20px;
        border-top: 1px solid #E2E7ED;
        border-left: 1px solid #E2E7ED;
    }
    .inner-table-margin-bottom{
        margin-bottom: 20px;
    }
}
</style>
